<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>展开运算符</title>
</head>

<body>
  <script type="text/javascript">

    // 在函数中使用
    function sum(...numbers) {
      return numbers.reduce((pre, cur) => {
        return pre + cur
      })
    }
    console.log(sum(1, 2, 3, 4))

    // 构造字面量对象时展开语法
    let person = { name: 'tom', age: 18 }
    let person2 = {...person}
    person2.name = 'jerry'
    console.log(person2)
    console.log(person)

    let person3 = person
    person3.name= 'xiaoli'
    console.log(person3)
    console.log(person)

    

  </script>
</body>

</html>